package fr.umlv.m2.uwp2011.persistence.user.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import fr.umlv.m2.uwp2011.persistence.matiere.dao.HibernateTroncCommunDAO;
import fr.umlv.m2.uwp2011.persistence.user.IUser_TroncCommunDAO;
import fr.umlv.m2.uwp2011.persistence.user.User_TroncCommun;

public class HibernateUser_TroncCommunDAO implements IUser_TroncCommunDAO {
	private final static HibernateTroncCommunDAO troncCommunDAO = new HibernateTroncCommunDAO();
	private static final Map<Long, List<User_TroncCommun>> mapTroncCommunUser = new HashMap<Long, List<User_TroncCommun>>();
	static {
		//----- troncCommun with id 1 -------//
		Long tronc_id = 1L;
		List<User_TroncCommun> list = new ArrayList<User_TroncCommun>();
		User_TroncCommun userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud1");
		list.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list);
		
		//----- troncCommun with id 2 -------//
		tronc_id = 2L;
		List<User_TroncCommun> list2 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud2");
		list2.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list2);
		
		//----- troncCommun with id 3 -------//
		tronc_id = 3L;
		List<User_TroncCommun> list3 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud2");
		list3.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list3);
		
		//----- troncCommun with id 4 -------//
		tronc_id = 4L;
		List<User_TroncCommun> list4 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud3");
		list4.add(userTroncCommun);
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud4");
		list4.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list4);
		
		//----- troncCommun with id 5 -------//
		tronc_id = 5L;
		List<User_TroncCommun> list5 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud5");
		list5.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list5);
		
		//----- troncCommun with id 6 -------//
		tronc_id = 6L;
		List<User_TroncCommun> list6 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud4");
		list6.add(userTroncCommun);
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud6");
		list6.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list6);
		
		//----- troncCommun with id 7 -------//
		tronc_id = 7L;
		List<User_TroncCommun> list7 = new ArrayList<User_TroncCommun>();
		userTroncCommun = new User_TroncCommun();
		userTroncCommun.setTroncCommun(troncCommunDAO.findById(tronc_id));
		userTroncCommun.setUser_id("etud7");
		list7.add(userTroncCommun);
		mapTroncCommunUser.put(tronc_id, list7);		
	}

	@Override
	public List<User_TroncCommun> findUser_TroncCommunByTroncCommunID(Long troncCommun_id) {
		return mapTroncCommunUser.get(troncCommun_id);
	}
}
